#导包
import requests

#准备测试数据
url = "http://www.litemall360.com:8080/wx/auth/login"
d = {
    "username":"user123",
    "password":"user123"
}
#进行测试，保存结果
r = requests.post(url, json=d)
#打印状态码和文本
print(r.status_code)
print(r.text)
t = r.json()
#把token保存到变量token中
token = t["data"]["token"]



#访问第二个接口
#准备测试数据
url2 = "http://www.litemall360.com:8080/wx/cart/add"
d2 = {"goodsId":1181000,"number":1,"productId":2}
h2 = {"X-Litemall-Token":token}
#发请求
r2 = requests.post(url2, json=d2, headers=h2)
#打印状态码和文本
print(r2.status_code)
print(r2.text)